package com.hmdp.config;

import com.hmdp.utils.LoginInterceptor;
import com.hmdp.utils.RefreshInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor()).excludePathPatterns(
                "/user/code","/user/login","/blog/hot","/shop/**","/upload/**","/shop-type/**","/voucher/**"
        ).order(1);
        registry.addInterceptor(refreshInterceptor()).addPathPatterns("/**").order(0);
    }
    @Bean
    public LoginInterceptor loginInterceptor(){
           return new LoginInterceptor();
    }
    @Bean
    public RefreshInterceptor refreshInterceptor(){
           return new RefreshInterceptor();
    }

}
